package com.gitee.client;

import com.gitee.enums.ResponseEnum;
import com.gitee.exception.CookbookException;
import com.gitee.sdk.CookbookSDK;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PutMapping;

@FeignClient(name = "canteen-wx-cookbook", fallback = CookbookFoodClient.CookbookFoodClientFallBack.class)
public interface CookbookFoodClient {

    @PutMapping("/client/cookbook/stock")
    void updateByCookbookIdAndFoodId(Integer cookbookId, Integer foodId, Integer stock);

    @Component
    static class CookbookFoodClientFallBack implements CookbookClient {

        @Override
        public CookbookSDK getTodayCookbook(Integer cookbookType) {
            throw new CookbookException(ResponseEnum.ERROR);
        }
    }
}
